#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int takeAttendance(vector<int>& records)
    {
        int left = 0, rigth = records.size() - 1;
        while (left < rigth)
        {
            int mid = left + (rigth - left) / 2;
            if (records[mid] == mid) left = mid + 1;
            else rigth = mid;
        }
        if (records[left] == left) return left + 1;
        else return left;

    }
};